Skip to content

feat[manual-only]: implement retrival of licenses from CLS server#35246

Merged
guanshengliang merged 19 commits into
mainfrom
feat/6665336277-main-v2
May 10, 2026
Merged

feat[manual-only]: implement retrival of licenses from CLS server#35246
guanshengliang merged 19 commits into
mainfrom
feat/6665336277-main-v2

Conversation

@acerDebugman
Copy link
Copy Markdown
Contributor

Closes 6665336277

Description

Issue(s)

  • Close/close/Fix/fix/Resolve/resolve: Issue Link

Checklist

Please check the items in the checklist if applicable.

  • Is the user manual updated?
  • Are the test cases passed and automated?
  • Is there no significant decrease in test coverage?

acerDebugman and others added 7 commits April 28, 2026 10:40
Define CLS response grant storage types and limits for SDB.
Support cached CLS grant state in mnode metadata.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Clamp altered CLS refresh intervals and preserve the last explicit value.
Use derived refresh intervals during clsEnabled state transitions and cover them with tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move ALTER normalization to mnd config handling and drop the extra tconfig clamp path.
Narrow the cached refresh interval type to int32.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rename the persisted CLS grant type and SDB key to the grant cls naming.
Add extend payload fields to the shared metadata struct.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rename the persisted CLS grant enum to match the grant cache naming.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 28, 2026 03:08
@acerDebugman acerDebugman requested a review from dapan1121 as a code owner April 28, 2026 03:08
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements the CLS (Cloud License Service) configuration and heartbeat functionality, adding new global variables, message types, and dynamic configuration logic. The review feedback identifies a potential performance issue where the message queue could be flooded when CLS is disabled, and highlights several code quality improvements, including the removal of dead code and redundant TODO comments. Additionally, the reviewer noted inconsistencies in interval validation ranges, the use of magic numbers, and suggested returning errors for invalid inputs instead of silently clamping values.

Comment thread source/dnode/mnode/impl/src/mndMain.c Outdated
Comment thread source/common/src/tglobal.c Outdated
Comment thread source/common/src/tglobal.c Outdated
Comment thread source/common/src/tglobal.c Outdated
Comment thread source/dnode/mnode/impl/src/mndConfig.c Outdated
Comment thread source/dnode/mnode/impl/src/mndMain.c Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds CLS (license retrieval) configuration and scheduling hooks so enterprise builds can periodically pull license data from a CLS server, including config validation/normalization and new message/SDB type definitions.

Changes:

  • Introduce CLS-related global configs (clsEnabled, clsUrl, clsLicenseId, clsRefreshInterval) and dynamic update handling.
  • Add an mnode timer pullup path + new RPC timer message type (TDMT_MND_CLS_HB_TIMER) for CLS refresh.
  • Add/adjust unit tests intended to cover CLS dynamic config behavior.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
source/util/test/cfgTest.cpp Adds a unit test for clsRefreshInterval alter/range behavior.
source/util/src/tconfig.c Minor formatting/line alignment change.
source/dnode/mnode/sdb/inc/sdb.h Adds new SDB type SDB_GRANT_CLS and bumps SDB_MAX.
source/dnode/mnode/impl/src/mndMain.c Adds CLS timer pullup and includes CLS timer msg in state checks.
source/dnode/mnode/impl/src/mndConfig.c Normalizes clsRefreshInterval on alter requests (enterprise-only).
source/dnode/mnode/impl/inc/mndDef.h Adds SGrantClsObj structure for CLS grant/response storage.
source/common/test/commonTests.cpp Adds a fixture/test for CLS dynamic config transitions.
source/common/src/tglobal.c Adds CLS globals + validation and enable/disable transition handling.
include/util/tdef.h Adds TSDB_GRANT_CLS_RESP_LEN constant.
include/common/tmsgdef.h Adds new message type TDMT_MND_CLS_HB_TIMER.
include/common/tglobal.h Exposes CLS globals via extern declarations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/dnode/mnode/impl/src/mndMain.c Outdated
Comment thread source/common/src/tglobal.c Outdated
Comment thread source/util/test/cfgTest.cpp Outdated
Comment thread source/common/test/commonTests.cpp
Joe Zhang and others added 2 commits April 28, 2026 11:37
Set the public cls refresh interval range to 10..86400 and simplify the derived interval helpers.
Drop stale commented code in the timer pullup path.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 28, 2026 05:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Enterprise-only configuration knobs and timer plumbing intended to periodically refresh CLS (license) information from a CLS server.

Changes:

  • Introduces new global config options for CLS (clsEnabled, clsUrl, clsLicenseId, clsRefreshInterval) and dynamic-update handling.
  • Adds a new mnode timer message type (TDMT_MND_CLS_HB_TIMER) and schedules periodic CLS pullups.
  • Adds/updates unit tests around CLS dynamic config behavior and config range handling.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
source/util/test/cfgTest.cpp Adds a new unit test for clsRefreshInterval alter/range behavior.
source/util/src/tconfig.c No functional change (formatting/line alignment).
source/dnode/mnode/sdb/inc/sdb.h Adds SDB_GRANT_CLS enum entry and bumps SDB_MAX.
source/dnode/mnode/impl/src/mndMain.c Adds CLS timer pullup builder/scheduler and allows timer bypass during restore/stop checks.
source/dnode/mnode/impl/src/mndConfig.c Adds normalization/clamping for clsRefreshInterval on alter requests.
source/dnode/mnode/impl/inc/mndDef.h Adds SGrantClsObj state struct.
source/common/test/commonTests.cpp Adds Enterprise-only test for CLS enable/refresh interval transition behavior.
source/common/src/tglobal.c Defines new CLS globals, adds config registration, validation, and dynamic update logic.
include/util/tdef.h Adds TSDB_GRANT_CLS_RESP_LEN size constant.
include/common/tmsgdef.h Adds new message type definition TDMT_MND_CLS_HB_TIMER.
include/common/tglobal.h Exposes CLS globals via extern declarations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/dnode/mnode/impl/src/mndMain.c Outdated
Comment thread source/dnode/mnode/impl/src/mndMain.c
Comment thread source/util/test/cfgTest.cpp Outdated
Match cfg-layer behavior by rejecting out-of-range updates\nand keeping the configured value unchanged when set fails.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread source/dnode/mnode/impl/src/mndConfig.c Outdated
Comment thread source/dnode/mnode/impl/src/mndMain.c Outdated
Comment thread source/common/src/tglobal.c
Expose clsQuotaSlotId as a server config option and update dynamic config handling.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@kailixu kailixu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comments

Comment thread source/dnode/mnode/impl/inc/mndDef.h
Add CLS transition markers and status config, keep timer pullups active during CLS state changes, and remove grant-specific definitions from community code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 8, 2026 09:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.

Comment thread source/dnode/mnode/impl/src/mndMain.c
Comment thread source/common/src/tglobal.c
Comment thread source/common/src/tglobal.c Outdated
Joe Zhang and others added 3 commits May 8, 2026 20:12
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 9, 2026 00:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.

Comment thread source/dnode/mnode/sdb/inc/sdb.h
Comment thread source/common/src/tglobal.c Outdated
Joe Zhang and others added 3 commits May 9, 2026 09:24
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 9, 2026 03:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.

Comment thread source/dnode/mnode/impl/src/mndMain.c
Comment thread source/common/src/tglobal.c
@sheyanjie-qq
Copy link
Copy Markdown
Contributor

High — New message type inserted in the middle of protocol enum, breaking wire protocol ID compatibility

  • File: include/common/tmsgdef.h:494
  • Issue: TDMT_MND_CLS_HB_TIMER was inserted in the middle of the TDMT_MND_EXT_MSG segment, even though the file convention
    requires new messages to be appended to the segment tail.
  • Impact: TD_DEF_MSG_TYPE assigns IDs sequentially, so inserting this in the middle shifts existing message IDs and can break
    RPC compatibility during rolling upgrades or mixed-version deployments.
  • Suggested fix: Move TDMT_MND_CLS_HB_TIMER to the end of the TDMT_MND_EXT_MSG segment, immediately before
    TD_CLOSE_MSG_SEG(TDMT_MND_EXT_MSG).

Move TDMT_MND_CLS_HB_TIMER to the end of the segment, before
TD_CLOSE_MSG_SEG(TDMT_MND_EXT_MSG), to maintain wire protocol
ID compatibility. Inserting in the middle shifts existing message
IDs and breaks RPC compatibility during rolling upgrades.
@acerDebugman
Copy link
Copy Markdown
Contributor Author

High — New message type inserted in the middle of protocol enum, breaking wire protocol ID compatibility

  • File: include/common/tmsgdef.h:494
  • Issue: TDMT_MND_CLS_HB_TIMER was inserted in the middle of the TDMT_MND_EXT_MSG segment, even though the file convention
    requires new messages to be appended to the segment tail.
  • Impact: TD_DEF_MSG_TYPE assigns IDs sequentially, so inserting this in the middle shifts existing message IDs and can break
    RPC compatibility during rolling upgrades or mixed-version deployments.
  • Suggested fix: Move TDMT_MND_CLS_HB_TIMER to the end of the TDMT_MND_EXT_MSG segment, immediately before
    TD_CLOSE_MSG_SEG(TDMT_MND_EXT_MSG).

fixed

@guanshengliang guanshengliang merged commit b5ecfbe into main May 10, 2026
9 checks passed
@guanshengliang guanshengliang deleted the feat/6665336277-main-v2 branch May 10, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants